<?php
/**
 * wmfl.cn version 5.0
 * -----------------------------------------------
 * @author sy <409014125@qq.com>
 * @link http://www.utuo88.com
 * @copyright 2014 Utuo Tech co.,Ltd
 */
namespace Partner\Model;
use Utuo\PartnerModel;

/**
 * 管理员行为模型
 * @author huajie <banhuajie@163.com>
 */
class PartnerAdminModel extends PartnerModel {

	protected $_fields = array("pid","name","email","password","group","last_login_time","last_login_ip","login_count","is_deleted","status","_pk"=>"id");

	protected $_validate = array(
			array('name','require','管理员姓名必须',self::MUST_VALIDATE),
			array('email','','管理员Email已经存在',self::EXISTS_VALIDATE, 'unique'),
			array('email','email','管理员Email格式不正确',self::EXISTS_VALIDATE),
	);

	protected $_auto = array(
			array('password', 'getPassword', self::MODEL_BOTH, 'callback'),
			array('last_login_time', 'time', self::MODEL_UPDATE, 'function'),
			array('last_login_ip', 'get_client_ip', self::MODEL_UPDATE, 'function'),
	);
	
	public function getPassword() {
		$password = I("password");
		if(!isset($_REQUEST['password']) or empty($password)) return false;
		return hash_pwd($password);
	}
}
